import cv2
import os

fps = 24  # 帧率
image_list = []  # 图片列表
for i in range(1, 301):
    filename = f'D:/picture/library/library-{i}.jpg'
    image_list.insert(0, filename)

# 读取第一张图片，获取图像尺寸信息
image = cv2.imread(image_list[0])
height, width, channels = image.shape

# 创建视频编写器
output_video = cv2.VideoWriter("video/output.mp4", cv2.VideoWriter_fourcc(*"mp4v"), fps, (width, height))

# 将图片写入视频帧
for image_path in image_list:
    image = cv2.imread(image_path)
    output_video.write(image)

# 释放资源
output_video.release()
cv2.destroyAllWindows()
